@echo off
for /F %%i in ('netstat -an^|find "TCP" /c') do ( set TCP=%%i)
for /F %%i in ('netstat -an^|find "CLOSED" /c') do ( set CLOSED=%%i)
for /F %%i in ('netstat -an^|find "LISTEN" /c') do ( set LISTEN=%%i)
for /F %%i in ('netstat -an^|find "SYN_RECV" /c') do ( set SYN_RECV=%%i)
for /F %%i in ('netstat -an^|find "SYN_SENT" /c') do ( set SYN_SENT=%%i)
for /F %%i in ('netstat -an^|find "ESTABLISHED" /c') do ( set ESTABLISHED=%%i)
for /F %%i in ('netstat -an^|find "TIME_WAIT" /c') do ( set TIME_WAIT=%%i)
set tmpstr=%date%%time%,%TCP%,%CLOSED%,%LISTEN%,%SYN_RECV%,%SYN_SENT%,%ESTABLISHED%,%TIME_WAIT%
set filename=%date:/=-%
set filename=%filename:~0,10%_csv.txt
echo %tmpstr% >> %filename%